# export function prototypes to thisfile.h
# use:
# <% export "int dostuff(int x)" %> {
#   return x;
# }

safeguard = @outputname.split('.')[0].upcase + "_H"
@header = File.new(@outputname.split('.')[0] + ".h", "w")
@header.puts "#infndef #{safeguard}"
@header.puts "#define #{safeguard}"

def export(str)
  @header.puts str + ";"
  print str
end

@finally << Proc.new do
  @header.puts "#endif"
  @header.close
end

# include things in header
# use:
# <% header do %>
#   #typedef struct { float x; float y; float z; } vector
#   #typedef unsigned char byte
# <% end %>

def header(&blk)
  @header.instance_eval &blk
end
